package own.stu.inter.loadbalance.chooseRule;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import own.stu.inter.loadbalance.ILoadBalancer;

import java.util.concurrent.TimeUnit;

public abstract class AbstractChooseRule implements IChooseRule {

    protected static Logger logger = LoggerFactory.getLogger(AbstractChooseRule.class);

    protected ILoadBalancer lb;

    public AbstractChooseRule(ILoadBalancer lb) {
        this.lb = lb;
    }

    protected void sleepAWhile(long millSec) {
        try {
            TimeUnit.MILLISECONDS.sleep(millSec);
        } catch (InterruptedException e) {
            logger.error("{} sleepAWhile interrupted ", Thread.currentThread().getName(), e);
        }
    }
}